%!TEX program = xelatex
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt,t,aspectratio=169,mathserif]{beamer}
%Other possible values are: 1610, 149, 54, 43 and 32. By default, it is to 128mm by 96mm(4:3).
%run XeLaTeX to compile.

\input{wang-slides-preamble.tex}

\begin{document}

\title{第7章：Sympy 模块}
%(1.1-1.2) 
%\institute{上海立信会计金融学院}
\author{JMS LQW}
%\date{2021年3月12日}

\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[fragile=singleslide]{6.1.1. }
\begin{frame}{目录 }

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{enumerate}
\item[7.1.]  计算机代数系统
\item[7.2.]  符号与函数
\item[7.3.]  Python与SymPy之间的转换
\item[7.4.]  矩阵和向量
\item[7.5.]  初等微积分
\item[7.6.]  等式、符号等式和化简
\item[7.7.]  方程求解
\item[7.8.]  常微分方程求解
\item[7.9.]  在 SymPy 中绘图
\end{enumerate}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.1. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：什么是计算机代数系统？

\item  问：什么是 Reduce, 什么是 Maxima?

\item  问：什么是 Maple, 什么是 Mathematica?

\item  问：什么是 SageMath?

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.2. 符号和函数}
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何创建符号变量？如何创建带符号变量的运算表达式

\begin{python}
import sympy as sy
sy.init_printing()
x,y = sy.symbols('x y')
D = (x+y)*sy.exp(x)*sy.cos(y)
type(x)
type(y)
type(D)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何创建符号变量 $x,y$ 的一个未知表达式的二元函数？

\begin{python}
import sympy as sy
x,y = sy.symbols('x y')
f, g = sy.symbols('f g', cls = sy.Function)
f(x)
f(x,y)
g(x)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何定义符号变量，并限制其取值范围是整数或实数？
\item  问：虚数单位 $\sqrt{-1}$, 自然底数 $e$, 圆周率 $\pi$ 和无穷大 $\infty$  在 Sympy 中是如何表示的？

\begin{python}
import sympy as sy
i,j = sy.symbols('i j', integer=True)
u,v = sy.symbols('u,v', real=True)
i.is_integer
j*j
(j*j).is_integer
i.is_real
a=sy.I; b=sy.E; c=sy.pi; d=sy.oo
a*a
\end{python}


\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：Sympy 模块中的符号变量 \verb+x+ 是一个类的实例，它有哪些可以使用的属性？
\begin{python}
import sympy as sy
x = sy.symbols('x', real=True)
\end{python}

\item  问：如何将表达式中的符号变量用特定的值代替？
\begin{python}
import sympy as sy
sy.init_printing()
x,y = sy.symbols('x y')
D = (x+y)*sy.exp(x)*sy.exp(y)
D0=D.subs(x,0)
D0pi=D0.subs(y,sy.pi)
D.subs([(x,0), (y,sy.pi)])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.3. Python 和 Sympy 之间的转换}
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：整数型符号变量如何与有理数组成一个符号表达式？
\begin{python}
import sympy as sy
x = sy.symbols('x', integer=True)
D=x+1/3
D1=x+sy.Rational(1,3)
D2=sy.Rational('0.5')*x
type(D1)
type(D2)
D3=x+sy.S('1/3')
D4=sy.S('1/2')*x
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：函数 sy.simplify 是怎么使用的？
\begin{python}
import sympy as sy
x,y = sy.symbols('x,y', real=True)
D_s = sy.simplify('(x+y)*exp(x)*cos(y)')
cosdiff = sy.simplify('cos(x)*cos(y)+sin(x)*sin(y)')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何将符号变量代入具体数值，计算符号表达式的数值结果？

\begin{python}
import sympy as sy
x,y = sy.symbols('x,y', real=True)
D_s = sy.simplify('(x+y)*exp(x)*cos(y)')
#cosdiff = sy.simplify('cos(x)*cos(y)+sin(x)*sin(y)')
cosdiff = sy.cos(x-y)
cospi4 = cosdiff.subs([(x,sy.pi/2),(y,sy.pi/4)])
cospi4
cospi4.evalf()
cospi4.evalf(6)
sy.N(cospi4,6)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何在符号表达式中，用一组数值代替一个符号变量？

\begin{python}
import numpy as np
import sympy as sy
x,y = sy.symbols('x,y')
cosdiff = sy.cos(x-y)

func = sy.lambdify((x,y),cosdiff,'numpy')
xn = np.linspace(0,np.pi,13)
z=func(xn,0.0)

import matplotlib.pyplot as plt
plt.plot(xn,z,'bo-')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.7\textwidth]{pic/fig-7-3.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.4. 矩阵和向量 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何在 Sympy 中创建一个 Matrix 类？如何对带符号变量的矩阵进行运算？

\begin{python}
import sympy as sy
x,y,u,v = sy.symbols('x,y,u,v')
M = sy.Matrix([ [1,x], [y,1] ])
V = sy.Matrix([ [u],[v] ])
M*V
M.eigenvects()
M.T
M.det()
M.inv()
M*M.inv()
M[0,1]=u
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.1. 微分 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何对符号表达式中的符号变量进行微分？

\begin{python}
import sympy as sy
x,y = sy.symbols('x,y')
D = (x+y)*sy.exp(x)*sy.cos(y)
sy.diff(D,x)
D.diff(x); D.diff(x,y,y); D.diff(y,2,x)
f = sy.symbols('f', cls=sy.Function)
f(x,y).diff(y,2,x)
\end{python}

\item  问：什么是惰性微分？什么是延迟计算？
\begin{python}
D_xyy = sy.Derivative(D,x,y,2)
D_xyy
D_xyy.doit()
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.2. 积分  }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何对符号表达式中的符号变量进行积分？什么是惰性积分？

\begin{python}
import sympy as sy
x,y = sy.symbols('x,y')
D = (x+y)*sy.exp(x)*sy.cos(y)
sy.integrate(D,y)
D.integrate(y)
D.integrate(x,y)

yD=sy.Integral(D,y)
yD
yD.doit()
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：用符号变量计算定积分 $$\int_{y=0}^{y=\pi} (x+y)e^x\cos(y)dy.$$

\begin{python}
import sympy as sy
x,y = sy.symbols('x,y')
D = (x+y)*sy.exp(x)*sy.cos(y)

sy.integrate(D,(y,0,sy.pi))
D.integrate((y,0,sy.pi))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：用符号变量计算二重积分 $$\int_{x=0}^{x=\infty}\int_{y=0}^{y=\infty} e^{-x^2-y}dxdy.$$

\begin{python}
import sympy as sy
x,y = sy.symbols('x,y')
D=sy.exp(-x**2-y**2)
sy.integrate(D, (x,0,sy.oo), (y,0,sy.oo))

dint = sy.Integral(D, (x,0,sy.oo), (y,0,sy.oo))
dint
dint.doit()
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.2. 一些困难的带符号变量的函数的积分 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：使用计算机代数计算符号积分 $$\int \frac{\sqrt{x+\sqrt{x^2+1} } }{x}dx. $$
\begin{python}
D1 = sy.sqrt(x+sy.sqrt(x**2+1))/x
sy.integrate(D1,x)
\end{python}

\item  问：使用计算机代数计算符号积分 $$\int_{x=1}^{x=\infty} \frac{e^{-x}\sin(x^2)}{x} dx. $$
\begin{python}
D2 = sy.exp(-x)*sy.sin(x**2)/x
sy.integrate(D2,(x,1,sy.oo))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：使用计算机代数计算下述两个符号积分 $$\int \frac{x}{\sin(x)} dx, \,\,\,\, \int e^{\sin(x)}dx. $$

\begin{python}
D3 = x/sy.sin(x)
sy.integrate(D3,x)

D4 = sy.exp(sy.sin(x))
sy.integrate(D4,x)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.3. 级数与极限 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：将函数 $y=e^{\sin(x)}$ 泰勒展开到10阶，并求积分。

\begin{python}
import sympy as sy
x = sy.symbols('x')

foo = sy.exp(sy.sin(x))
foo_ser = foo.series(x,0,10)
foo_ser
foo_ser.integrate(x)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.5.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求函数 $y=\frac{e^{\sin(x)}-1-x}{x^2}$ 当 $x\to 0$ 时的极限。
\begin{python}
hoo = (foo-1-x)/x**2
sy.limit(hoo,x,0)
\end{python}

\item  问：求函数 $y=\frac{1}{x-1}$ 当 $x\to 1$ 时的单侧极限。
\begin{python}
goo = 1/(x-1)
sy.limit(goo,x,1)
sy.limit(goo,x,1,dir='-')
sy.limit(goo,x,1,dir='+')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.6. 等式、符号等式和化简 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：在 Sympy 里，如何测试两个表达式是否相同？

\begin{python}
12/3 == 4
import sympy as sy
x,y = sy.symbols('x,y')
ex1 = (x+y)**2
ex2 = x**2 + 2*x*y + y**2
ex1 == ex2
ex1-ex2 == 0

ex1.expand() == ex2
ex1 == ex2.factor()
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.6. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何展开一个三角函数的表达式？
\begin{python}
sy.expand_trig(sy.sin(x+y))
sy.expand(sy.cos(x-y),trig=True)
#sy.expand<tab>
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.6. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何通过合并同类项等运算，化简一个表达式？
\begin{python}
import sympy as sy
x,y=sy.symbols('x,y')
M=sy.Matrix([[1,x],[y,1]])
A=M*M.inv()
A
A[0,0]=A[0,0].cancel()
A
A[1,1]=A[1,1].cancel()
A
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.6. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：为什么 sy.cancel() 不是默认的输出方式？
\begin{python}
import sympy as sy
x=sy.symbols('x')
C=(x**64-1)/(x-1)
C.cancel()
#C.factor()
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7. 方程求解 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：如何在 Sympy 里创建一个方程？
\begin{python}
import sympy as sy
x,y=sy.symbols('x,y')
D=(x+y)*sy.exp(x)*sy.exp(y)
cosdiff=sy.cos(x-y)
lhs=D
rhs=cosdiff
eqn1=sy.Eq(lhs,rhs)
eqn2=lhs-rhs
eqn1
eqn2
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：在 Sympy 里的求解方程的函数有哪些？
\begin{python}
import sympy as sy
from sympy.solvers import solveset
from sympy.solvers.solveset import linsolve
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.1. 单变量方程 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解代数方程 $4x-3=0$ 与 $3x^3-16x^2+23x-6=0$. 
\begin{python}
x,y=sy.symbols('x,y')
solveset(4*x-3,x)
solveset(3*x**3-16*x**2+23*x-6,x)
\end{python}

\item  问：求解代数方程 $x^2-2x+1=0$. 
\begin{python}
quad=x**2-2*x+1
solveset(quad,x)
sy.roots(quad)
\end{python}

\item  问：求解方程 $e^x-1=0$ 与 $\cos(x)-x=0$.  

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.2. 具有多个自变量的线性方程组 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：设 $A$ 是一个 $n\times n$ 阶的实矩阵，什么是 $A$ 的核？什么是 $A$ 的值域？

\item  答：
\begin{itemize}
\item  $A$ 的核是指 $\{ x\in\mathbb{R}^n\mid  Ax=0\}$, 即齐次线性方程组 $Ax=0$ 的解空间。
\item  $A$ 的值域是 $\{Ax\mid x\in \mathbb{R}^n\}$, 即矩阵 $A$ 的列空间。
\end{itemize}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：Sympy 的 linsolve 函数如何求解线性方程组 
$$
\left\{\begin{array}{rcl}
x+2y&=&0,\\
3x+4y&=&2. 
\end{array}\right.
$$

\begin{python}
Eqns=[x+2*y,3*x+4*y-2]
linsolve(Eqns,[x,y])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：Sympy 的 linsolve 函数如何求解线性方程组 
$$
\left\{\begin{array}{rcl}
x+2y&=&1,\\
2x+4y&=&2. 
\end{array}\right.
$$

\begin{python}
A=sy.Matrix([[1,2],[3,4]])
b=sy.Matrix([[1],[2]])
linsolve((A,b),[x,y])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：Sympy 的 linsolve 函数如何求解线性方程组 
$$
\left\{\begin{array}{rcl}
x+2y&=&1,\\
2x+4y&=&1. 
\end{array}\right.
$$

\begin{python}
A_b=sy.Matrix([[1,2,1],[2,4,1]])
linsolve(A_b,[x,y])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解方程组
$$
\left\{\begin{array}{rcl}
y^2&=&(x+1)^2,\\
3x-y&=&1. 
\end{array}\right.
$$

\begin{python}
import sympy as sy
x,y=sy.symbols('x,y')
neq=[y**2-x**2-2*x-1, 3*x-y-1]

from sympy.solvers.solveset import linsolve
linsolve(neq,[x,y])

import sympy.solvers as sys
sys.solve(neq,[x,y])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.3. 更一般的方程组 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解非线性方程组
$$
\left\{\begin{array}{rcl}
\sqrt{x}-\sqrt{y}&=&1,\\
\sqrt{x+y}&=&2. 
\end{array}\right.
$$

\begin{python}
import sympy as sy
import sympy.solvers as sys
x,y=sy.symbols('x,y')
eqn1=sy.sqrt(x)-sy.sqrt(y)-1
eqn2=sy.sqrt(x+y)-2
sys.solve([eqn1,eqn2],[x,y])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.7.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解非线性方程 $\sqrt[3]{3x+1}=x+1$ 与 $\sqrt[3]{3x-1}=x-1$. 
\begin{python}
eq1=sy.root(3*x+1,3)-x-1
eq2=sy.root(3*x-1,3)-x+1
sys.solve(eq1,x)
sys.solve(eq2,x)

sys.solve(eq1,x,check=False)
sys.solve(eq2,x,check=False)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.1. 常微分方程的求解}
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $f''(x) +4f(x) =0$. 
\begin{python}
import sympy as sy
from sympy.solvers import dsolve
x=sy.symbols('x'); f,g=sy.symbols('f,g',cls=sy.Function)
ode1=f(x).diff(x,2)+4*f(x); sol1=dsolve(ode1,f(x))
\end{python}

%\item  通解为 $ y=C_1\sin(2x) + C_2\cos(2x) $. 

%\vspace{0.3cm}

\item  问：求解常微分方程初值问题 $f''(x) +4f(x) =0, \,\, f(0)=2, f'(0)=0$.  
\begin{python}
C1,C2=sy.symbols('C1,C2')
fun=sol1.rhs; fund=fun.diff(x)
fun.subs(x,0); fund.subs(x,0)
psol=sol1.subs([(C2,2),(C1,0)])
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $(x\cos(y) + y)y' + \sin(y) =0$. 
\begin{python}
import sympy as sy
from sympy.solvers import dsolve
x=sy.symbols('x')
f=sy.symbols('f',cls=sy.Function)

ode2=sy.sin(f(x))+(x*sy.cos(f(x))+f(x))*f(x).diff(x)
sol2=dsolve(ode2,f(x))
\end{python}

\item  通解为 $ x\sin(y) + \frac{1}{2}y^2=C $. 

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $xy' + y - \ln(x) y^2 =0$. 

\begin{python}
import sympy as sy
from sympy.solvers import dsolve
x=sy.symbols('x')
f=sy.symbols('f',cls=sy.Function)

ode3=x*f(x).diff(x)+f(x)-sy.log(x)*f(x)**2
dsolve(ode3)
\end{python}

\item  通解为 $ y=\frac{1}{Cx+\ln(x)+1}$. 

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.4. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $x^2f''(x) - 4xf'(x) + 6f(x) - x^3 = 0$. 
\begin{python}
ode4=f(x).diff(x,2)*x**2-4*f(x).diff(x)*x+6*f(x)-x**3
dsolve(ode4)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.5. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $f''(x)+f'(x)^2/f(x) + f'(x)/x =0$. 

\begin{python}
ode5=f(x).diff(x,2)+(f(x).diff(x))**2/f(x)+f(x).diff(x)/x
dsolve(ode5)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.6. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $xf''(x)+2f'(x)+xf(x)=0$. 

\begin{python}
ode6=x*(f(x).diff(x,2))+2*(f(x).diff(x))+x*f(x)
dsolve(ode6)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.7. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 
\begin{eqnarray*}
f'(x) &=& 2f(x) +g(x), \\
g'(x) &=& f(x) + 2g(x).
\end{eqnarray*}

\begin{python}
ode7=[f(x).diff(x)-2*f(x)-g(x), g(x).diff(x)-f(x)-2*g(x)]
dsolve(ode7)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.8. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $f'(x) = (x+f(x))^2$. 
\begin{python}
ode8=f(x).diff(x)-(x+f(x))**2
dsolve(ode8)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.8.9. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：求解常微分方程 $g'(x) = 1+g(x)^2$. 
\begin{python}
ode9=g(x).diff(x)-1-(g(x))**2
dsolve(ode9)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.1. 在 Sympy 中绘图 }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出 $y=\sin(x)$ 及其一些泰勒展开的图像，$$y=x, y=x-\frac{x^3}{6}, y=x-\frac{x^3}{6}+\frac{x^5}{120}. $$ 

\begin{python}
import sympy as sy
import sympy.plotting as syp
x=sy.symbols('x')
ss='sin(x) and its first three Taylor approximants'
syp.plot(sy.sin(x),x,x-x**3/6, x-x**3/6+x**5/120,
         (x,-4,4),title=ss)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.1. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-1.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出参数化的二维曲线 
\begin{eqnarray*}
\left\{\begin{array}{rcl}
x &=& \cos(t) +\frac{1}{2}\cos(7t) + \frac{1}{3}\cos(17t), \\
y &=& \sin(t) +\frac{1}{2}\sin(7t) + \frac{1}{3}\sin(17t). 
\end{array}\right.
\end{eqnarray*}

\begin{python}
u=sy.symbols('u')
xc=sy.cos(u)+sy.cos(7*u)/2+sy.sin(17*u)/3
yc=sy.sin(u)+sy.sin(7*u)/2+sy.cos(17*u)/3
fig2=syp.plot_parametric(xc,yc,(u,0,2*sy.pi))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.2. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-2.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出由方程 $x^2+xy+y^2=1$ 定义的平面曲线的图像。

\begin{python}
x,y=sy.symbols('x,y')
syp.plot_implicit(x**2+x*y+y**2-1,(x,-1.5,1.5),
                  (y,-1.5,1.5))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.3. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-3.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.4. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出方程 $|\cos(z^2)|=1$ 在复数平面中定义的曲线。

\begin{python}
import sympy as sy
import sympy.plotting as syp
x,y=sy.symbols('x,y',real=True)
z=x+sy.I*y
w=sy.cos(z**2).expand(complex=True)
wa=sy.Abs(w).expand(complex=True)
syp.plot_implicit(wa**2-1)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.4. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-4.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.5. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出由不等式定义的图形区域：$$xy>1, 0\le x\le 2, 0\le y\le 2.$$

\begin{python}
import sympy as sy
import sympy.plotting as syp
x,y=sy.symbols('x,y')
#syp.plot_implicit(sy.And(x*y>1,x**2+y**2<4),(x,0,2),
#                  (y,0,2),line_color='lightblue')
syp.plot_implicit(x*y>1,(x,0,2),(y,0,2),line_color='lightblue')
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.5. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-5.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.6. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出参数化的三维曲线的图像：$$x=u\cos(4u), y=u\sin(4u), z=u. $$

\begin{python}
import sympy as sy
import sympy.plotting as syp
x,y,u=sy.symbols('x,y,u')
x=u*sy.cos(4*u)
y=u*sy.sin(4*u)
z=u
syp.plot3d_parametric_line(x,y,z,(u,0,10))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.6. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-6.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.7. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出由二元函数 $y=x^2+y^2$ 与 $y=xy$ 定义的两个三维曲面的图像。

\begin{python}
import sympy as sy
import sympy.plotting as syp
x,y=sy.symbols('x,y')
syp.plot3d(x**2+y**2,x*y,(x,-3,3),(y,-3,3))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.7. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-7.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.8. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  问：画出参数化的三维曲面的图像：
\begin{eqnarray*}
\left\{\begin{array}{rcl}
x &=& (3+\sin(u)+\cos(v))\cos(2u), \\
y &=& (3+\sin(u)+\cos(v))\sin(2u), \\
z &=& 2\cos(u)+\sin(v). 
\end{array}\right.
\end{eqnarray*}

\begin{python}
import sympy as sy
import sympy.plotting as syp
u,v=sy.symbols('u,v')
x=(3+sy.sin(u)+sy.cos(v))*sy.cos(2*u)
y=(3+sy.sin(u)+sy.cos(v))*sy.sin(2*u)
z=2*sy.cos(u)+sy.sin(v)
syp.plot3d_parametric_surface(x,y,z,(u,0,2*sy.pi),(v,0,sy.pi))
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.9.8. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{figure}
\centering
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{pic/fig-7-9-8.png}
% \caption{ }
\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile=singleslide]{7.10. }
%\begin{frame}{}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{itemize}

\item  练习：在下述教材中，找一些例题或习题，使用 Sympy 进行求解。
\begin{itemize}
\item  数学分析
\item  高等代数
\item  解析几何
\item  常微分方程
\end{itemize}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{frame}[fragile=singleslide]{1.20. }
\begin{frame}{参考文献}

\vspace{-0.4cm}\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}
%每页详细内容

\begin{thebibliography}{99}
\bibitem{stewart-en} John M. Stewart. \emph{Python for Scientists}. Second Edition. Cambridge University Press. 2017. 
\bibitem{stewart-cn} 约翰.M.斯图尔特(著). 江红等(译). \emph{Python科学计算}，机械工业出版社，2019年8月第1版。

\end{thebibliography}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}


